var status = -1;
var beauty = 0;

function start() {
    action(1, 0, 0)
}

function action(d, c, b) {
    if (d == -1) {
        cm.dispose()
    } else {
        if (d == 0 && status == 0) {
            cm.dispose();
            return
        }
        if (d == 1) {
            status++
        } else {
            if (status == 0) {
                cm.dispose()
            }
            status--
        }
        if (status == 0) {
            if (cm.getJQ() == 0) {
                cm.sendOk("您当前#r金卷#k为#r" + cm.getJQ() + "#k无法进行兑换。");
                cm.dispose()
            } else {
                beauty = 1;
                cm.askNumber("#fMob/1210102.img/move/0##fMob/1210102.img/move/0##bPPMS - 143#fMob/1210102.img/move/0##fMob/1210102.img/move/0##k\r\n1张#r金卷 #k: #b100点卷#k \r\n#e你的账户信息#n\r\n#r金卷#k:#r" + cm.getJQ() + " #r张#k \r\n#b点卷#k:#b" + cm.getPlayer().getCSPoints(0) + " #b点#k\r\n#k请输入#r金卷#k兑换#b点卷#k的数量:", 1, 1, cm.getJQ())
            }
        } else {
            if (status == 1) {
                var a = b;
                if (beauty == 1) {
                    if (cm.getJQ() == 0) {
                        cm.sendOk("您当前#r金卷#k为#r" + cm.getJQ() + "#k无法进行兑换。");
                        cm.dispose()
                    } else {
                        if (b < 0) {
                            cm.sendOk("你输入的数负数!");
                            cm.dispose()
                        } else {
                            if (cm.getJQ() <= b * 1) {
                                cm.sendOk("你没有足够的#r金卷#k,我不能帮你。");
                                cm.dispose()
                            } else {
                                cm.addJQ(-a);
                                cm.getPlayer().modifyCSPoints(1, 100 * b);
                                cm.sendOk("兑换成功,你获得了" + 100 * b + "点卷,祝您游戏愉快。");
                                cm.dispose()
                            }
                        }
                    }
                }
            }
        }
    }
};